﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using FDSimpleModelGenerator.Aop;
using FDSimpleModelGenerator.Entities;

namespace FDSimpleModelGenerator.IServices
{
    /// <summary>
    /// 基础服务接口
    /// </summary>
    public interface IBasicService<T> where T : new()
    {
        /// <summary>
        /// 获取单个
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T Get(int id);

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        [SystemLog(LogActionAfterCall = true)]
        IList<T> GetList();

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        bool Add(T classTemplate);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        bool Update(T classTemplate);

        /// <summary>
        /// 新增或更新
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        bool AddOrUpdate(T classTemplate);

        /// <summary>
        /// 删除操作
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Delete(int id);


        /// <summary>
        /// 获取单个
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> GetAsync(int id);

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        Task<IList<T>> GetListAsync();

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        Task<bool> AddAsync(T classTemplate);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(T classTemplate);

        /// <summary>
        /// 新增或更新
        /// </summary>
        /// <param name="classTemplate"></param>
        /// <returns></returns>
        Task<bool> AddOrUpdateAsync(T classTemplate);

        /// <summary>
        /// 删除操作
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);
    }
}
